Improve browser cleanup, local browser PATH setup, and screenshot recovery#1001
Closed
davetist wants to merge 3 commits intoNousResearch:mainfrom
Closed
Improve browser cleanup, local browser PATH setup, and screenshot recovery#1001davetist wants to merge 3 commits intoNousResearch:mainfrom
davetist wants to merge 3 commits intoNousResearch:mainfrom
Conversation
Unify browser session teardown so manual close, inactivity cleanup, and emergency shutdown all follow the same cleanup path instead of partially duplicating logic. This changes browser_close() to delegate to cleanup_browser(), which means recording shutdown, Browserbase release, activity bookkeeping cleanup, and local socket-directory removal now happen consistently. It also updates emergency cleanup to route through cleanup_all_browsers() and explicitly clear in-memory tracking state after teardown so stale active-session, last-activity, and recording entries are not left behind on exit. The screenshot fallback path has also been fixed. _extract_screenshot_path_from_text() now matches real absolute PNG paths, including quoted output, so browser_vision() can recover screenshots when agent-browser emits human-readable text instead of JSON. Regression coverage was added in tests/tools/test_browser_cleanup.py for screenshot path extraction, cleanup_browser() state removal, browser_close() delegation, and emergency cleanup state clearing. Verified with: - python -m pytest tests/tools/test_browser_cleanup.py -q - python -m pytest tests/tools/test_browser_console.py tests/gateway/test_send_image_file.py -q
117b984 to
73bbfdf
Compare
Contributor
Author
|
It modifies the session id too because apparently in macOS if the name is too long it doesn't work |
Contributor
Author
|
Added more context to the PR description |
teknium1
added a commit
that referenced
this pull request
Mar 14, 2026
Resolve the cherry-pick against current browser_tool structure without carrying unrelated formatting churn, while preserving the intended cleanup, PATH, and screenshot recovery changes from PR #1001.
Contributor
|
Merged via #1333. I cherry-picked your substantive browser cleanup/screenshot recovery commit onto current main, resolved it against the current browser tool structure, and kept the new cleanup + screenshot regression coverage. |
Contributor
Author
|
@teknium1 i love you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR keeps the browser fixes that still add value on top of the latest
main:agent-browserexecution more reliable by preferring the Hermes-managed Node binary inPATHagent-browserreturns human-readable output instead of JSONWhat Changed
Cleanup and session lifecycle
browser_close()to delegate tocleanup_browser()instead of performing a partial inline shutdown_emergency_cleanup_all_sessions()to route throughcleanup_all_browsers()and then clear:_active_sessions_session_last_activity_recording_sessionsLocal browser command reliability
_run_browser_command()to prefer$HERMES_HOME/node/binbefore the standard system path entriesPATHfor minimal service environmentsScreenshot and non-JSON handling
_extract_screenshot_path_from_text()to recover real absolute.pngpaths from human-readableagent-browseroutputbrowser_vision()to:--fulltoagent-browser screenshotTests
tests/tools/test_browser_cleanup.pycoverage for:cleanup_browser()state cleanupbrowser_close()delegationNot Included
mainbehavior that removed browser signal handlersVerification
Passed:
source venv/bin/activate && python -m pytest tests/tools/test_browser_cleanup.py tests/tools/test_browser_console.py tests/gateway/test_send_image_file.py -qCurrent full-suite state on this branch:
source venv/bin/activate && python -m pytest tests/ -qtests/run_interrupt_test.pywithSystemExit/ xdist internal errors